<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>v-model修饰符</h2>
      <!-- lazy修饰符是将input事件换成了change事件 -->
      <!-- 需要失去焦点 -->
      <input type="text" v-model.lazy="textValue" />
      <p>textValue: {{ textValue }}</p>

      <!-- 使用parseFloat将字符串转成数字 -->
      <input type="text" v-model.number="numValue" />
      <p>numValue: {{ numValue }} - {{ typeof numValue }}</p>

      <!-- trim修饰符用于去掉首尾空格 -->
      <input type="text" v-model.trim="trimValue" />
      <p>trimValue: {{ trimValue }}</p>
      <button @click="fn">btn</button>
    </div>

    <script src="./lib/Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            textValue: "123",
            numValue: 10,
            trimValue: "",
          };
        },
        methods: {
          fn() {
            console.log(this.trimValue);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
